const btnRegister = document.querySelector('#btn-register')//提交按钮
const registerForm =document.querySelector('.register-form')//注册表单


registerForm.addEventListener('submit', function (e) {
	e.preventDefault()
	console.log(111);
	const data = serialize(registerForm, { hash: true, empty: true })
	
	if (!/[a-zA-Z0-9]{2,30}/.test(data.username)) {
		toast('请输2-30入账号')
		return
	}
	if (!/[a-zA-Z0-9]{6,30}/.test(data.password)) {
		toast('请输6-30入密码')
		return
	}
	
	axios({ url: '/register', method: 'POST', data })
	.then(res => {
		toast(res.message)
	 		 setTimeout(() => {
				location.href='./login.html'
	 		 }, 1000);

	}).catch(err => {
		toast(err.response.data.message)
	}) 


})





